<?xml version="1.0" encoding="UTF-8"?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	template="../../Template-Acueil.xhtml">
	<ui:define name="title"></ui:define>
	<ui:define name="body">

		<h:outputLink id="loginLink" value="javascript:void(0)"
			onclick="dlg.show()" title="login">
			<p:graphicImage value="../Manage_Accueil/1.jpg" />
		</h:outputLink>

		<p:dialog id="dialog" header="Login" widgetVar="dlg">
			<h:form>

				<h:panelGrid columns="2" cellpadding="5">
					<h:outputLabel for="username" value="Username: *" />
					<p:inputText value="#{loginBean.username}" id="username"
						required="true" label="username" />

					<h:outputLabel for="password" value="Password: * " />
					<h:inputSecret value="#{loginBean.password}" id="password"
						required="true" label="password" />

					<f:facet name="footer">
						<p:commandButton value="Login" actionListener="#{loginBean.login}"
							oncomplete="handleLoginRequest(xhr, status, args)" />
					</f:facet>
				</h:panelGrid>

			</h:form>
		</p:dialog>

		<script type="text/javascript">
	function handleLoginRequest(xhr, status, args) {
		if(args.validationFailed || !args.loggedIn) {
			jQuery('#dialog').parent().effect("shake", { times:3 }, 100);
		} else {
			dlg.hide();
			jQuery('#loginLink').fadeOut();
		}
	}
</script>


	</ui:define>

</ui:composition>